<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>对象冒充</title>
</head>
<body>
    <script>
        // 看起来是继承了，实际上是假的.
        // 实现的是属性的继承，原型方法的继承不能实现
        function Animal(name,color) {
            this.name = name
            this.color = color
        }
        Animal.prototype.showName = _ => {
            console.log(this.name)
        }

        function Dog(name,color,age) {
            this.age = age
            // 对象冒充
            // this.Animal = Animal
            // this.Animal(name,color)
            Animal.call(this,name,color)
            delete Dog.Animal
        }
        const dog = new Dog('hashiqi','green',12)
        console.log(dog)
        // dog.showName() // 并没有这个方法
    </script>
</body>
</html>